Skip to content

Refactor Sidebar to responsive drawer pattern with mobile support#65

Merged
mnindrazaka merged 1 commit intomainfrom
claude/responsive-design-phase-1-J0ya6
Apr 25, 2026
Merged

Refactor Sidebar to responsive drawer pattern with mobile support#65
mnindrazaka merged 1 commit intomainfrom
claude/responsive-design-phase-1-J0ya6

Conversation

@mnindrazaka
Copy link
Copy Markdown
Collaborator

Summary

Refactored the Sidebar component to support responsive layouts with a mobile-first approach. On mobile/tablet devices, the sidebar now renders as an off-canvas Sheet drawer, while desktop maintains the classic inline sidebar. Updated the Layout component to manage sidebar state and added responsive utilities.

Key Changes

  • Sidebar Component Refactoring

    • Moved sidebar state management (isShown, onToggle) from internal hook to parent Layout component via props
    • Extracted sidebar content into reusable sidebarContent variable to avoid duplication
    • Added responsive rendering: Sheet drawer for mobile/tablet (≤md), inline sidebar for desktop (>md)
    • Removed ChevronsLeft icon import and simplified toggle button logic
    • Added useMedia() hook for responsive breakpoint detection
    • Improved accessibility with data-testid attributes
  • Layout Component Enhancement

    • Added sidebar state management with useState and useEffect
    • Sidebar defaults to open on desktop, closed on mobile/tablet
    • Added hamburger menu button (Menu icon) that appears only on mobile/tablet
    • Passed hamburger button as leftActionItem to Navbar
    • Wrapped children in new ContentContainer component for max-width constraint
    • Added responsive padding adjustments ($xs, $sm breakpoints)
  • Navbar Component Updates

    • Added leftActionItem prop to support hamburger menu button
    • Improved responsive layout with flex direction change on mobile
    • Added text truncation to title with numberOfLines and ellipsizeMode
    • Better alignment and spacing for mobile views
  • New Components

    • ContentContainer: Centers content with max-width (1440px) constraint
    • ResponsiveStack: Responsive XStack that switches to column layout on medium screens
  • Sidebar State Hook Cleanup

    • Removed isShown and onToggleButtonPress from useSidebarState
    • Added SSR safety check for window object access
    • Removed unused import

Implementation Details

The responsive behavior uses Tamagui's useMedia() hook to detect breakpoints:

  • Mobile/Tablet (≤md): Sidebar renders as a Sheet drawer overlay, toggled by hamburger menu
  • Desktop (>md): Sidebar renders as a fixed inline component with slide animation

State is managed at the Layout level to coordinate sidebar visibility across the entire layout, ensuring consistent behavior across all child components.

https://claude.ai/code/session_01R25cNRQMhafRu4VQ7njNFL

Phase 0 - Foundation:
- Add ContentContainer: max-width 1440 centered wrapper for large screens
- Add ResponsiveStack: XStack that collapses to column at $md breakpoint

Phase 1 - Layout Shell:
- Sidebar: off-canvas Sheet drawer on mobile/tablet ($md and below),
  classic inline sidebar on desktop ($gtMd); visibility state lifted to Layout
- Sidebar.state: remove isShown (now managed by Layout), fix SSR-unsafe
  window.location.pathname with typeof window guard
- Navbar: add leftActionItem prop, $xs column stacking, numberOfLines+ellipsis
  on title for overflow safety
- Layout: manage sidebar open/close state via useMedia() for viewport-aware
  defaults (open on desktop, closed on mobile); add hamburger button for
  mobile; responsive content padding ($3/$4/$5 by breakpoint); wrap children
  in ContentContainer

https://claude.ai/code/session_01R25cNRQMhafRu4VQ7njNFL
@mnindrazaka mnindrazaka merged commit d11feac into main Apr 25, 2026
@mnindrazaka mnindrazaka deleted the claude/responsive-design-phase-1-J0ya6 branch April 25, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants